#include <iostream>

using namespace std;

long int commonDivisor(long int a, long int b){
	int max,min;
	if(a > b){
		max = a;
		min = b;
	} else {
		max = b;
		min = a;
	}
	long int temp;
	while(max % min != 0){
		temp = max % min;
		max = min;
		min = temp;
	}
	return min;
}

long int commonMultiple(long int a, long int b){
	long int div= commonDivisor(a, b);
	return (a/div)*(b/div)*div;
}

int main(){
	long int div;
	long int mul;
	cin >> div >> mul;
	if((div > mul) || (mul%div != 0)){
		cout << 0 << endl;
		return 0;
	}
	int upBound = mul / div;
	int mount = 0;
	for(int x = 1; x <= upBound; x++)
		for(int y = 1; y <= upBound; y++)
			if(commonDivisor(div * x, div * y) == div && commonMultiple(div * x, div * y) == mul)
				mount++;
	cout << mount << endl;
}
